package com.freedy.concurrent.Monitors.sharingProblem;

import lombok.extern.slf4j.Slf4j;

/**
 * 线程八锁
 * 情况1：12 或 21
 * @author Freedy
 * @date 2021/4/20 22:47
 */
public class Test4 {
    public static void main(String[] args) {
        Number n1 = new Number();
        new Thread(()->{ n1.a(); }).start();
        new Thread(()->{ n1.b(); }).start();
    }
}
@Slf4j
class Number{
    public synchronized void a() {
        log.debug("1");
    }
    public synchronized void b() {
        log.debug("2");
    }
}